//
//  NewsCell.m
//  CarLife
//
//  Created by yu on 2018/1/9.
//  Copyright © 2018年 jpas. All rights reserved.
//

#import "NewsCell.h"

@implementation NewsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    CGFloat margin15 = 15; CGFloat margin10 = 10;
    UIView *contentView = self.contentView;
    
    _imgView.sd_layout
    .rightSpaceToView(contentView, margin15)
    .topSpaceToView(contentView, margin10)
    .widthIs(kAutoWidth(100))
    .autoHeightRatio(0.75);
    
    _titleLabel.sd_layout
    .leftSpaceToView(contentView, margin15)
    .topSpaceToView(contentView, margin10*1.5)
    .rightSpaceToView(_imgView, margin10)
    .autoHeightRatio(0);
    
    _authorLabel.sd_layout
    .topSpaceToView(_titleLabel, margin10*1.3)
    .leftSpaceToView(contentView, margin15)
    .heightIs(margin15);
    [_authorLabel setSingleLineAutoResizeWithMaxWidth:kScreenWidth/2];
    
    _timeLabel.sd_layout
    .centerYEqualToView(_authorLabel)
    .leftSpaceToView(_authorLabel, margin10)
    .heightIs(margin15);
    [_timeLabel setSingleLineAutoResizeWithMaxWidth:kScreenWidth/2];
    
    [self setupAutoHeightWithBottomViewsArray:@[_authorLabel,_imgView] bottomMargin:margin10];
}

- (void)setNewsModel:(NewsModel *)newsModel
{
    _newsModel = newsModel;
    
    self.titleLabel.text = newsModel.title;
    self.authorLabel.text = NSStringFormat(@"来源：%@",newsModel.author_name);
    self.timeLabel.text = newsModel.date;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:newsModel.thumbnail_pic_s] placeholderImage:IMAGE_NAMED(@"dance")];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end



